package thirdpart.checksum;

/**
 * @Author: Tzu
 * @Date: 2020/11/11 20:48
 * @Version: 1.0
 * @Description:
 */
public class ByteCheckSum implements ICheckSum {
    @Override
    public byte getChecksum(byte[] data) {
        byte sum = 0;
        for (byte b : data) {
            //对数据所有字节进行异或累加
            sum ^= b;
        }
        return sum;
    }


//    public static void main(String[] args) {
//        String a = "test";
//        String b = "test1";
//        String c = "test";
//
//        ByteCheckSum checkSum = new ByteCheckSum();
//        byte ba =  checkSum.getChecksum(a.getBytes());
//        byte bb =  checkSum.getChecksum(b.getBytes());
//        byte bc =  checkSum.getChecksum(c.getBytes());
//
//        System.out.println(ba);
//        System.out.println(bb);
//        System.out.println(bc);
//    }

}
